#include "recbase.h"
#include <typeinfo>

using namespace std;
using namespace opsrc::stdf;


RecBase::RecBase()
{
	stdfrec = UNK;   		// enum stdf_rec type
	fileRecByteStartPosition = -1;
	
}

RecBase::RecBase(stdf_rec _stdfrec, int _reclen, std::ios::pos_type _fileRecFirstBytePosition, int _orderindex) {
        stdfrec = _stdfrec;
        reclen = _reclen;
        fileRecByteStartPosition = _fileRecFirstBytePosition;
        orderIndex = _orderindex;
}


RecBase::~RecBase() {
}

void RecBase::setStdfRec(stdf_rec stdfrectype) {
    this->stdfrec = stdfrectype;
}

stdf_rec RecBase::getStdfRec() const {
	return stdfrec;
}

int RecBase::getRecByteCount() const {
	return reclen;
}

void RecBase::setRecByteCount(int reclen) {
	this->reclen = reclen;
}

void RecBase::setRecOrder(int order) {
	this->orderIndex = order;
}

int RecBase::getRecOrder() const {
    return this->orderIndex;	
}
	
void RecBase::printHexa(char* buffer, int size, ostream& strm) {
	   std::ios::fmtflags tmp = strm.flags();
	   strm << std::showbase << std::hex;
	   for ( int i=0; i< size; i++ )
	   {
	    	int val = static_cast<int> (buffer[i]);
	    	if (val==0)
	    	   strm << "0x0 ";
	    	else	
    	       strm << val << " ";
	   }
	   
	    strm << endl;
	    strm.flush();
	    
		strm.flags(tmp); // restore	
	
}

long RecBase::getFileRecByteStartPosition() const {
	return (long)fileRecByteStartPosition;
}


void RecBase::readFields(char *) {
}
